<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function intersection (nums1, nums2) {
      return [...new Set(nums1.filter(item => nums2.includes(item)))]  
    };
    const nums1 = [4,9,5]
    const nums2 = [9,4,9,8,4]
    console.log(intersection(nums1,nums2));
  </script>
</body>
</html>